// pages/i_detail/i_detail.js
const app = getApp()
var get_order_info;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    info:{},
    b_list:[],
    oid:'',
    role_id:0,
    is:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var id = options.id;
    var aid = wx.getStorageSync('uid');
    var role_id = app.data.role_id;
    get_order_info = app.data.index_url + 'get_order_info';
    wx.request({
      url: get_order_info,
      data: {
        id:id,
        uid:aid
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success (res) {
        console.log(res.data);
        var info = res.data.info;
        var b_list = res.data.b_list;
        var is = res.data.is;
        that.setData({
          info:info,
          b_list:b_list,
          oid:id,
          role_id:role_id,
          is:is
        })
      }
    })
  },
  previewImgxc: function (e) {
    var that = this;
    var info = that.data.info;
    var photos = info.photos_images;
    var index = e.currentTarget.dataset.index;
    wx.previewImage({
      current: photos[index],     //当前图片地址
      urls: photos               //所有要预览的图片的地址集合 数组形式
    })
  },
  xqtap:function(e){
    var that = this;
    var uid = that.data.info.uid;
    var order_status = that.data.info.order_status;
    var pay_status = that.data.info.pay_status;
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/i_detailxq/i_detailxq?id='+id+'&uid='+uid+'&order_status='+order_status+'&pay_status='+pay_status,
    })
  },
  submit:function(e){
    var oid = this.data.oid;
    var is = this.data.is;
    if(is == null){
      wx.navigateTo({
        url: '/pages/i_offer/i_offer?oid='+oid,
      })
    }else{
      wx.showModal({
        title: '提示',
        content: '您已报价，不可重复报价！',
        showCancel: false
      })
    }
  },
  /** 
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})